#include <stdio.h>
int main()
{
    int m, n, k;
    scanf("%d%d",&m,&n);
    k = m;
    while(m % k != 0 || n % k != 0)
    {
          k--;
    }
    printf("%d\n", k);
    return 0;
}
